package com.xbb.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xbb.entity.Membership;
import com.xbb.entity.dto.MembershipDto;
import com.xbb.service.MemberShipService;
import com.xbb.util.Result;

@RestController
public class MemberShipController {

	@Autowired
	MemberShipService memberShipService;
	
	@RequestMapping("/getMemList")
	public Object getMemList(MembershipDto membershipDto,ModelMap map) {
		List<MembershipDto> list = memberShipService.getMems(membershipDto);
		membershipDto.setLimit(null);
		membershipDto.setPage(null);
		List<MembershipDto> list2 = memberShipService.getMems(membershipDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addMem")
	public Object addMem(Membership membership) {
		if(memberShipService.addMem(membership)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	@RequestMapping("/updateMem")
	public Object updateMem(Membership membership) {
		if(memberShipService.updateMem(membership)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delMem")
	public Object delMem(int memid) {
		if(memberShipService.delMem(memid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
	
	
}
